<?php
/*
 * Created on 04.01.2006
 *
 */

m2import('phpinchains/Filter.php');
m2import('admin/user.o.inc.php');
m2import('dba/DataSource.php');
m2import('dba/dbaPermission.o.inc.php');
m2import('base/ApplicationContext.php');

/**
 * Filter which calls the old admin view controller views
 */
class AdminEnvironmentFilter extends phpinchains_Filter
{

    private $config;

    function init (& $config)
    {
        $this->config = $config;
    }

    function doFilter (& $env, & $chain)
    {
        if (empty($GLOBALS['udba']))
            $GLOBALS['udba']  = dba_DataSource::getInstance()->getConnection();
        $env = env::getInstance();
        $env->setConfig('__usr', new user($env->getSession('s_user'), $GLOBALS['udba']));
        $env->setZombie('__usr', $env->getConfig('__usr'));
        $ctx = base_ApplicationContext::getInstance();
        $mediaPath = $ctx->mediaPath();
        $env->setConfig('mediaPath', array('core' => $mediaPath->core(), 'mod' => $mediaPath->mod()));
        $env->setConfig('cfgPaths', $ctx->cfgPaths());
        $chain->doFilter($env);
    }

}

?>